/*
 ============================================================================
 Name        : TelephonyTestNewFile.h
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : TelephonyTestNewFile.h - header file
 ============================================================================
 */

#include "DialCall.h"
CDialCall::CDialCall() :
	CActive(EPriorityStandard)
	{
	//default constructor
	CActiveScheduler::Add(this);
	}

CDialCall::~CDialCall()
	{
	Cancel();
	delete iTelephony;
	}

CDialCall* CDialCall::NewL()
	{
	CDialCall* pSelf = new (ELeave) CDialCall;
	CleanupStack::PushL(pSelf);
	pSelf->ConstructL();
	CleanupStack::Pop();
	return pSelf;
	}

void CDialCall::ConstructL()
	{
	iTelephony = CTelephony::NewL();
	}

void CDialCall::DialNewCall(const TDesC& aPhoneNumber)
	{
	if (IsActive())
		{
//		return;
		Cancel();
		}
	CTelephony::TTelNumber telNumber(aPhoneNumber);
	CTelephony::TCallParamsV1 callParams;
	callParams.iIdRestrict = CTelephony::ESendMyId;
	CTelephony::TCallParamsV1Pckg callParamsPckg(callParams);
	iTelephony->DialNewCall(iStatus, callParamsPckg, telNumber, iCallId);
	SetActive();
	}

void CDialCall::RunL()
	{
	if (iStatus == KErrNone)
		{
		Cancel();
		} // The call has been dialled successfully;
	// iCallId contains the call's ID, needed when controlling the call.
	}

void CDialCall::DoCancel()
	{
	iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
	}

